import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface UserInType {
  name: string;
  age: number;
}

const userSlice = createSlice({
  name: "user",
  initialState: {
    user: {
      name: "",
      age: 0,
    },
  },
  reducers: {
    setUser(state, action: PayloadAction<UserInType>) {
      state.user = action.payload;
    },
  },
});

export const { setUser } = userSlice.actions;
export default userSlice.reducer;
